<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>预约挂号</title>
    <script src="js/jquery.min.js"></script>
    <script src="js/tagetUrl.js"></script>
    <script src="js/dayjs.min.js"></script>
    <link rel="stylesheet" type="text/css" href="css/aui.css"/>
    <link rel="stylesheet" type="text/css" href="css/main.css"/>
    <script>
        $(function () {

            let hosId = location.href.split("?")[1];
            if (location.href.split("?").length > 1) {
                $.ajax({
                    type: "get",
                    url: targetUrl + "/wechat114/getHospitalInfo",
                    data: {"hosId": hosId},
                    dataType: "json",
                    success(data) {
                        if (data.code === 1) {
                            $(".hospital-info").empty();
                            $("#hos_logo").attr("src", data.data.hospitalLogo);
                            $(".hospital-info").append("<h4>" + data.data.hospitalName + "</h4>" +
                                "<p>" + data.data.hospitalType + "</p>" +
                                "<p>每日" + dayjs(data.data.openTime).format('HH:mm') + "开放第" + data.data.openDay + "日号源</p>")
                        }
                    }
                })

                $.ajax({
                    type: "get",
                    url: targetUrl + "/wechat114/getMainDepartment",
                    dataType: "json",
                    success(data) {
                        if (data.code === 1) {
                            $(".type-left-list").empty();

                            for (var i = 0; i < data.data.length; i++) {
                                if (i === 0) {
                                    $(".type-left-list")
                                        .append("<div class='type-left-item type-active' id=" + data.data[i].id + ">" +
                                            "<i></i>" +
                                            "<a href='javascript:;' >" + data.data[i].deptName + "</a>" +
                                            "</div>");
                                } else {
                                    $(".type-left-list")
                                        .append("<div class='type-left-item' id=" + data.data[i].id + ">" +
                                            "<i></i>" +
                                            "<a href='javascript:;'>" + data.data[i].deptName + "</a>" +
                                            "</div>");
                                }

                            }

                        }
                    }
                })

                $.ajax({
                    type: "get",
                    url: targetUrl + "/wechat114/getSecondDepartment",
                    data: {"deptId": 1},
                    dataType: "json",
                    success(data) {
                        $(".type-right-list").empty();
                        for (var i = 0; i < data.data.length; i++) {
                            $(".type-right-list")
                                .append("<div className='type-right-item'>" +
                                    "<a href='yuyue.html?" + hosId + "?" + data.data[i].id + "'>" + data.data[i].deptName + "</a>" +
                                    "</div>");
                        }
                    }
                })
            }

        })
    </script>
</head>
<body>
<div class="site-name">
    <p>北京114预约挂号平台</p>
</div>
<div class="hospital-container">
    <div class="hospital-wrapper">
        <div class="hospital-logo">
            <img src="" id="hos_logo" alt="">
        </div>
        <div class="hospital-info">
        </div>
        <a class="hospital-look" href="hoslook.html">
            <img src="images/look.png" alt="">
            <span>医院详情</span>
        </a>
    </div>
    <div class="search-container">
        <div class="search-wrapper">
            <div class="search-icon">
                <i class="aui-iconfont aui-icon-search"></i>
            </div>
            <div class="search-input">
                <input placeholder="搜索医院" autocomplete="off"/>
            </div>
        </div>
    </div>
</div>

<div class="type-container hospital-type-container">
    <div class="type-left">
        <div class="type-left-list">
            <!--            <div class="type-left-item type-active">-->
            <!--                <i></i>-->
            <!--                <a href="javascript:;">核酸检测</a>-->
            <!--            </div>-->
            <!--            <div class="type-left-item">-->
            <!--                <i></i>-->
            <!--                <a href="javascript:;">全科医疗科</a>-->
            <!--            </div>-->
            <!--            <div class="type-left-item">-->
            <!--                <i></i>-->
            <!--                <a href="javascript:;">内科</a>-->
            <!--            </div>-->
            <!--            <div class="type-left-item">-->
            <!--                <i></i>-->
            <!--                <a href="javascript:;">外科</a>-->
            <!--            </div>-->
            <!--            <div class="type-left-item">-->
            <!--                <i></i>-->
            <!--                <a href="javascript:;">重症医学科</a>-->
            <!--            </div>-->
            <!--            <div class="type-left-item">-->
            <!--                <i></i>-->
            <!--                <a href="javascript:;">急症介入科</a>-->
            <!--            </div>-->
            <!--            <div class="type-left-item">-->
            <!--                <i></i>-->
            <!--                <a href="javascript:;">肿瘤科</a>-->
            <!--            </div>-->
            <!--            <div class="type-left-item">-->
            <!--                <i></i>-->
            <!--                <a href="javascript:;">妇产科</a>-->
            <!--            </div>-->
            <!--            <div class="type-left-item">-->
            <!--                <i></i>-->
            <!--                <a href="javascript:;">儿科</a>-->
            <!--            </div>-->
            <!--            <div class="type-left-item">-->
            <!--                <i></i>-->
            <!--                <a href="javascript:;">小儿外科</a>-->
            <!--            </div>-->
            <!--            <div class="type-left-item">-->
            <!--                <i></i>-->
            <!--                <a href="javascript:;">眼科</a>-->
            <!--            </div>-->
            <!--            <div class="type-left-item">-->
            <!--                <i></i>-->
            <!--                <a href="javascript:;">耳鼻喉头颈外科</a>-->
            <!--            </div>-->
            <!--            <div class="type-left-item">-->
            <!--                <i></i>-->
            <!--                <a href="javascript:;">口腔科</a>-->
            <!--            </div>-->
            <!--            <div class="type-left-item">-->
            <!--                <i></i>-->
            <!--                <a href="javascript:;">皮肤科</a>-->
            <!--            </div>-->
            <!--            <div class="type-left-item">-->
            <!--                <i></i>-->
            <!--                <a href="javascript:;">医疗美容科</a>-->
            <!--            </div>-->
            <!--            <div class="type-left-item">-->
            <!--                <i></i>-->
            <!--                <a href="javascript:;">精神科</a>-->
            <!--            </div>-->
            <!--            <div class="type-left-item">-->
            <!--                <i></i>-->
            <!--                <a href="javascript:;">结核病科</a>-->
            <!--            </div>-->
            <!--            <div class="type-left-item">-->
            <!--                <i></i>-->
            <!--                <a href="javascript:;">地方病科</a>-->
            <!--            </div>-->
            <!--            <div class="type-left-item">-->
            <!--                <i></i>-->
            <!--                <a href="javascript:;">康复医学科</a>-->
            <!--            </div>-->
        </div>
    </div>
    <div class="type-right">
        <div class="type-right-list">
            <!--            <div class="type-right-item">-->
            <!--                <a href="yuyue.html"></a>-->
            <!--            </div>-->
        </div>
    </div>
</div>

</body>
<script>
    let hosId = location.href.split("?")[1];
    $('.type-left-list').delegate('.type-left-item', "click", function () {
        $.ajax({
            type: "get",
            url: targetUrl + "/wechat114/getSecondDepartment",
            data: {"deptId": this.id},
            dataType: "json",
            success(data) {
                $(".type-right-list").empty();
                for (var i = 0; i < data.data.length; i++) {
                    $(".type-right-list")
                        .append("<div className='type-right-item'>" +
                            "<a href='yuyue.html?" + hosId + "?" + data.data[i].id + "'>" + data.data[i].deptName + "</a>" +
                            "</div>");
                }
            }
        })
    })


    $('.type-left-list').delegate('.type-left-item', 'click', function () {
        $('.type-left-item').removeClass('type-active');
        $(this).addClass('type-active');
    })

    $('.type-left-item').click(function () {
        $('.type-left-item').removeClass('type-active');
        $(this).addClass('type-active');
    })


</script>
</html>
